﻿using System;
using System.Collections.Generic;
using UnityEngine;

namespace com.tdb.foundation
{
    public class LocalizationManager
    {
        private LocalizationManager()
        {
        }

        private Dictionary<string, string> _textDic;
    
        public string Get(string key, params object[] contents)
        {
            string result;
            if (_textDic.TryGetValue(key, out result))
            {
                if (contents.Length > 0)
                {
                    try
                    {
                        result = string.Format(result, contents);
                    }
                    catch 
                    {
                        Debug.LogError("Key:"+key+" format failed!");
                    }
                }
                return result;
            }
            else
            {
                return key;
            }
        }
    }

}

